//
// Created by chengs1r on 2021/8/14.
//

#include <stdio.h>
#include <stdlib.h>


int main(void) {
    FILE *fp = NULL;
    int c; //int c 才是正确的实现方式
    // char c; //遇到0xff的ASCii码字节，因为0x0000 00ff截断后赋值给c的是0xff 遇到int类型做比较，会拓展成0xffff ffff与EOF相等，循环终止
    // unsigned char c; //0x0000 00ff != 0xffff ffff 无限循环输出0xff
    fp = fopen("/Users/chengs1r/Code/CLionProjects/c-basis/EOF介绍/en.txt", "r");
    if (fp == NULL) {
        printf("不能够访问该文件.\n");
        exit(1);
    }
    while ((c = fgetc(fp)) != EOF) {
        printf("%c = %#x\n", c, c);
    }
    fclose(fp);
    fp = NULL;
    return 0;
}

